const ruleUtils = {
    validatePhone: (rule, value, callback) => {
        if (!value) {
            return callback(new Error("手机号不能为空"));
        } else {
            const reg = /^1[3|4|5|7|8][0-9]\d{8}$/;
            if (reg.test(value)) {
                callback();
            } else {
                return callback(new Error("请输入正确的手机号"));
            }
        }
    },
    validateMoney: (rule, value, callback) => {
        if (!value) {
            return callback(new Error("金额不能为空"));
        } else {
            const reg = /^(([1-9][0-9]*\.[0-9][0-9]*)|([0]\.[0-9][0-9]*)|([1-9][0-9]*)|([0]{1}))$/;
            if (reg.test(value)) {
                callback();
            } else {
                return callback(new Error("请输入正确的金额"));
            }
        }
    },
    validatePositiveInteger: (rule, value, callback) => {
        const reg = /^[+]{0,1}(\d+)$/;
        if (reg.test(value)) {
            callback();
        } else {
            return callback(new Error("请输入正确的数字"));
        }
    },
}

export default ruleUtils;